package org.biloxi.commands.playerlost;

import org.biloxi.commands.CommandRepository;
import org.biloxi.commands.impl.CommandImpl;
import org.biloxi.model.mutable.GameStateMutable;
import org.biloxi.player.PlayerID;

public class PlayerLost extends CommandImpl<PlayerLost.Options, PlayerLost.Result> {

	public static class Options {
		public final PlayerID losingPlayer;
		public Options(PlayerID losingPlayer) {
			this.losingPlayer = losingPlayer;
		}
	}

	public static class Result {
		public final PlayerID losingPlayer;
		public Result(PlayerID losingPlayer) {
			this.losingPlayer = losingPlayer;
		}
	}

	public PlayerLost(CommandRepository cr) {
		super(cr);
	}

	@Override
	protected Result executeImpl(Options o, GameStateMutable gameState) {
		gameState.mutablePlayerState(o.losingPlayer).setHasLost(true);
		return new Result(o.losingPlayer);
	}
}
